<?php

namespace App\Http\Requests\Api;

use Illuminate\Foundation\Http\FormRequest;

class CaptchaRequest extends FormRequest
{
    public function authorize()
    {
        return true;
    }

    public function rules()
    {
        return [
            'phone' => 'required|regex:/^((13[0-9])|(14[5,7])|(15[0-3,5-9])|(17[0,3,5-8])|(18[0-9])|166|198|199|(147))\d{8}$/|unique:users',
        ];
    }

    public function messages()
    {
        return [
            'phone.required' => '手机号码不能为空',
            'phone.regex'    => '手机号码格式不正确',
            'phone.unique'   => '手机号码已存在',
        ];
    }
}
